﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
   public class Fruit
    {
        public int id;
        public string name;
        public double price;

        public int Id
        {
            get
            {
                return id;
            }
            set
            {
                id = value;
            }
        }
        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                name = value;
            }
        }
        public double Price
        {
            get
            {
                return price;
            }
            set
            {
                if (value>0)
                {
                    price = value;  
                }
                else
                {
                    price = 0;
                }
            }
        }
        public void SetFruit(int id,string name,double price)
        {
            Id = id;
            Name = name;
            Price = price;
        }
        public void PrintMsg()
        {
            Console.WriteLine("水果的号数：{0}，\n水果的名字：{1},\n水果的价钱:{2}元",Id,Name,Price);
        }
    }
}
